package cn.qqtheme.framework.picker;

import android.app.Activity;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.qqtheme.framework.util.DateUtils;
import cn.qqtheme.framework.util.LogUtils;
import cn.qqtheme.framework.widget.WheelView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Locale;

/* loaded from: classes.dex */
public class DateTimePicker extends WheelPicker {
    @Deprecated
    public static final int HOUR = 4;
    public static final int HOUR_12 = 4;
    public static final int HOUR_24 = 3;
    @Deprecated
    public static final int HOUR_OF_DAY = 3;
    public static final int MONTH_DAY = 2;
    public static final int NONE = -1;
    public static final int YEAR_MONTH = 1;
    public static final int YEAR_MONTH_DAY = 0;
    private int dateMode;
    private String dayLabel;
    private ArrayList<String> days;
    private int endDay;
    private int endHour;
    private int endMinute;
    private int endMonth;
    private int endYear;
    private String hourLabel;
    private ArrayList<String> hours;
    private String minuteLabel;
    private ArrayList<String> minutes;
    private String monthLabel;
    private ArrayList<String> months;
    private OnDateTimePickListener onDateTimePickListener;
    private OnWheelListener onWheelListener;
    private boolean resetWhileWheel;
    private int selectedDayIndex;
    private String selectedHour;
    private String selectedMinute;
    private int selectedMonthIndex;
    private int selectedYearIndex;
    private int startDay;
    private int startHour;
    private int startMinute;
    private int startMonth;
    private int startYear;
    private int textSize;
    private int timeMode;
    private String yearLabel;
    private ArrayList<String> years;

    @Retention(RetentionPolicy.SOURCE)
    /* loaded from: classes.dex */
    public @interface DateMode {
    }

    /* loaded from: classes.dex */
    protected interface OnDateTimePickListener {
    }

    @Deprecated
    /* loaded from: classes.dex */
    public interface OnMonthDayPickListener extends OnMonthDayTimePickListener {
    }

    /* loaded from: classes.dex */
    public interface OnMonthDayTimePickListener extends OnDateTimePickListener {
        void onDateTimePicked(String str, String str2, String str3, String str4);
    }

    /* loaded from: classes.dex */
    public interface OnTimePickListener extends OnDateTimePickListener {
        void onDateTimePicked(String str, String str2);
    }

    /* loaded from: classes.dex */
    public interface OnWheelListener {
        void onDayWheeled(int i, String str);

        void onHourWheeled(int i, String str);

        void onMinuteWheeled(int i, String str);

        void onMonthWheeled(int i, String str);

        void onYearWheeled(int i, String str);
    }

    /* loaded from: classes.dex */
    public interface OnYearMonthDayTimePickListener extends OnDateTimePickListener {
        void onDateTimePicked(String str, String str2, String str3, String str4, String str5);
    }

    @Deprecated
    /* loaded from: classes.dex */
    public interface OnYearMonthPickListener extends OnYearMonthTimePickListener {
    }

    /* loaded from: classes.dex */
    public interface OnYearMonthTimePickListener extends OnDateTimePickListener {
        void onDateTimePicked(String str, String str2, String str3, String str4);
    }

    @Retention(RetentionPolicy.SOURCE)
    /* loaded from: classes.dex */
    public @interface TimeMode {
    }

    public DateTimePicker(Activity activity, int i) {
        this(activity, 0, i);
    }

    public DateTimePicker(Activity activity, int i, int i2) {
        super(activity);
        this.years = new ArrayList<>();
        this.months = new ArrayList<>();
        this.days = new ArrayList<>();
        this.hours = new ArrayList<>();
        this.minutes = new ArrayList<>();
        this.yearLabel = "年";
        this.monthLabel = "月";
        this.dayLabel = "日";
        this.hourLabel = "时";
        this.minuteLabel = "分";
        this.selectedYearIndex = 0;
        this.selectedMonthIndex = 0;
        this.selectedDayIndex = 0;
        this.selectedHour = "";
        this.selectedMinute = "";
        this.dateMode = 0;
        this.timeMode = 3;
        this.startYear = 2010;
        this.startMonth = 1;
        this.startDay = 1;
        this.endYear = 2020;
        this.endMonth = 12;
        this.endDay = 31;
        this.startMinute = 0;
        this.endMinute = 59;
        this.textSize = 16;
        this.resetWhileWheel = true;
        if (i == -1 && i2 == -1) {
            throw new IllegalArgumentException("The modes are NONE at the same time");
        }
        if (i == 0 && i2 != -1) {
            if (this.screenWidthPixels < 720) {
                this.textSize = 14;
            } else if (this.screenWidthPixels < 480) {
                this.textSize = 12;
            }
        }
        this.dateMode = i;
        if (i2 == 4) {
            this.startHour = 1;
            this.endHour = 12;
        } else {
            this.startHour = 0;
            this.endHour = 23;
        }
        this.timeMode = i2;
    }

    public void setResetWhileWheel(boolean z) {
        this.resetWhileWheel = z;
    }

    @Deprecated
    public void setRange(int i, int i2) {
        if (this.dateMode == -1) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        this.startYear = i;
        this.endYear = i2;
        initYearData();
    }

    public void setDateRangeStart(int i, int i2, int i3) {
        if (this.dateMode == -1) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        this.startYear = i;
        this.startMonth = i2;
        this.startDay = i3;
        initYearData();
    }

    public void setDateRangeEnd(int i, int i2, int i3) {
        if (this.dateMode == -1) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        this.endYear = i;
        this.endMonth = i2;
        this.endDay = i3;
        initYearData();
    }

    public void setDateRangeStart(int i, int i2) {
        int i3 = this.dateMode;
        if (i3 == -1) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        if (i3 == 0) {
            throw new IllegalArgumentException("Not support year/month/day mode");
        }
        if (i3 == 1) {
            this.startYear = i;
            this.startMonth = i2;
        } else if (i3 == 2) {
            int i4 = Calendar.getInstance(Locale.CHINA).get(1);
            this.endYear = i4;
            this.startYear = i4;
            this.startMonth = i;
            this.startDay = i2;
        }
        initYearData();
    }

    public void setDateRangeEnd(int i, int i2) {
        int i3 = this.dateMode;
        if (i3 == -1) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        if (i3 == 0) {
            throw new IllegalArgumentException("Not support year/month/day mode");
        }
        if (i3 == 1) {
            this.endYear = i;
            this.endMonth = i2;
        } else if (i3 == 2) {
            this.endMonth = i;
            this.endDay = i2;
        }
        initYearData();
    }

    public void setTimeRangeStart(int i, int i2) {
        if (this.timeMode == -1) {
            throw new IllegalArgumentException("Time mode invalid");
        }
        boolean z = false;
        z = (i < 0 || i2 < 0 || i2 > 59) ? true : true;
        if (this.timeMode == 4 && (i == 0 || i > 12)) {
            z = true;
        }
        if (this.timeMode == 3 && i >= 24) {
            z = true;
        }
        if (z) {
            throw new IllegalArgumentException("Time out of range");
        }
        this.startHour = i;
        this.startMinute = i2;
        initHourData();
    }

    public void setTimeRangeEnd(int i, int i2) {
        if (this.timeMode == -1) {
            throw new IllegalArgumentException("Time mode invalid");
        }
        boolean z = false;
        z = (i < 0 || i2 < 0 || i2 > 59) ? true : true;
        if (this.timeMode == 4 && (i == 0 || i > 12)) {
            z = true;
        }
        if (this.timeMode == 3 && i >= 24) {
            z = true;
        }
        if (z) {
            throw new IllegalArgumentException("Time out of range");
        }
        this.endHour = i;
        this.endMinute = i2;
        initHourData();
    }

    public void setLabel(String str, String str2, String str3, String str4, String str5) {
        this.yearLabel = str;
        this.monthLabel = str2;
        this.dayLabel = str3;
        this.hourLabel = str4;
        this.minuteLabel = str5;
    }

    public void setSelectedItem(int i, int i2, int i3, int i4, int i5) {
        if (this.dateMode != 0) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        LogUtils.verbose(this, "change months and days while set selected");
        changeMonthData(i);
        changeDayData(i, i2);
        this.selectedYearIndex = findItemIndex(this.years, i);
        this.selectedMonthIndex = findItemIndex(this.months, i2);
        this.selectedDayIndex = findItemIndex(this.days, i3);
        if (this.timeMode != -1) {
            this.selectedHour = DateUtils.fillZero(i4);
            this.selectedMinute = DateUtils.fillZero(i5);
        }
    }

    public void setSelectedItem(int i, int i2, int i3, int i4) {
        int i5 = this.dateMode;
        if (i5 == 0) {
            throw new IllegalArgumentException("Date mode invalid");
        }
        if (i5 == 2) {
            LogUtils.verbose(this, "change months and days while set selected");
            int i6 = Calendar.getInstance(Locale.CHINA).get(1);
            this.endYear = i6;
            this.startYear = i6;
            changeMonthData(i6);
            changeDayData(i6, i);
            this.selectedMonthIndex = findItemIndex(this.months, i);
            this.selectedDayIndex = findItemIndex(this.days, i2);
        } else if (i5 == 1) {
            LogUtils.verbose(this, "change months while set selected");
            changeMonthData(i);
            this.selectedYearIndex = findItemIndex(this.years, i);
            this.selectedMonthIndex = findItemIndex(this.months, i2);
        }
        if (this.timeMode != -1) {
            this.selectedHour = DateUtils.fillZero(i3);
            this.selectedMinute = DateUtils.fillZero(i4);
        }
    }

    public void setOnWheelListener(OnWheelListener onWheelListener) {
        this.onWheelListener = onWheelListener;
    }

    public void setOnDateTimePickListener(OnDateTimePickListener onDateTimePickListener) {
        this.onDateTimePickListener = onDateTimePickListener;
    }

    public String getSelectedYear() {
        int i = this.dateMode;
        if (i == 0 || i == 1) {
            if (this.years.size() <= this.selectedYearIndex) {
                this.selectedYearIndex = this.years.size() - 1;
            }
            return this.years.get(this.selectedYearIndex);
        }
        return "";
    }

    public String getSelectedMonth() {
        if (this.dateMode != -1) {
            if (this.months.size() <= this.selectedMonthIndex) {
                this.selectedMonthIndex = this.months.size() - 1;
            }
            return this.months.get(this.selectedMonthIndex);
        }
        return "";
    }

    public String getSelectedDay() {
        int i = this.dateMode;
        if (i == 0 || i == 2) {
            if (this.days.size() <= this.selectedDayIndex) {
                this.selectedDayIndex = this.days.size() - 1;
            }
            return this.days.get(this.selectedDayIndex);
        }
        return "";
    }

    public String getSelectedHour() {
        return this.timeMode != -1 ? this.selectedHour : "";
    }

    public String getSelectedMinute() {
        return this.timeMode != -1 ? this.selectedMinute : "";
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // cn.qqtheme.framework.popup.ConfirmPopup
    public View makeCenterView() {
        int i;
        int i2 = this.dateMode;
        if ((i2 == 0 || i2 == 1) && this.years.size() == 0) {
            LogUtils.verbose(this, "init years before make view");
            initYearData();
        }
        if (this.dateMode != -1 && this.months.size() == 0) {
            LogUtils.verbose(this, "init months before make view");
            changeMonthData(DateUtils.trimZero(getSelectedYear()));
        }
        int i3 = this.dateMode;
        if ((i3 == 0 || i3 == 2) && this.days.size() == 0) {
            LogUtils.verbose(this, "init days before make view");
            if (this.dateMode == 0) {
                i = DateUtils.trimZero(getSelectedYear());
            } else {
                i = Calendar.getInstance(Locale.CHINA).get(1);
            }
            changeDayData(i, DateUtils.trimZero(getSelectedMonth()));
        }
        if (this.timeMode != -1 && this.hours.size() == 0) {
            LogUtils.verbose(this, "init hours before make view");
            initHourData();
        }
        if (this.timeMode != -1 && this.minutes.size() == 0) {
            LogUtils.verbose(this, "init minutes before make view");
            changeMinuteData(DateUtils.trimZero(this.selectedHour));
        }
        LinearLayout linearLayout = new LinearLayout(this.activity);
        linearLayout.setOrientation(0);
        linearLayout.setGravity(17);
        WheelView createWheelView = createWheelView();
        final WheelView createWheelView2 = createWheelView();
        final WheelView createWheelView3 = createWheelView();
        WheelView createWheelView4 = createWheelView();
        final WheelView createWheelView5 = createWheelView();
        int i4 = this.dateMode;
        if (i4 == 0 || i4 == 1) {
            createWheelView.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
            createWheelView.setItems(this.years, this.selectedYearIndex);
            createWheelView.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DateTimePicker.1
                @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
                public void onSelected(int i5) {
                    DateTimePicker.this.selectedYearIndex = i5;
                    String str = (String) DateTimePicker.this.years.get(DateTimePicker.this.selectedYearIndex);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onYearWheeled(DateTimePicker.this.selectedYearIndex, str);
                    }
                    LogUtils.verbose(this, "change months after year wheeled");
                    if (DateTimePicker.this.resetWhileWheel) {
                        DateTimePicker.this.selectedMonthIndex = 0;
                        DateTimePicker.this.selectedDayIndex = 0;
                    }
                    int trimZero = DateUtils.trimZero(str);
                    DateTimePicker.this.changeMonthData(trimZero);
                    createWheelView2.setItems(DateTimePicker.this.months, DateTimePicker.this.selectedMonthIndex);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onMonthWheeled(DateTimePicker.this.selectedMonthIndex, (String) DateTimePicker.this.months.get(DateTimePicker.this.selectedMonthIndex));
                    }
                    DateTimePicker dateTimePicker = DateTimePicker.this;
                    dateTimePicker.changeDayData(trimZero, DateUtils.trimZero((String) dateTimePicker.months.get(DateTimePicker.this.selectedMonthIndex)));
                    createWheelView3.setItems(DateTimePicker.this.days, DateTimePicker.this.selectedDayIndex);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onDayWheeled(DateTimePicker.this.selectedDayIndex, (String) DateTimePicker.this.days.get(DateTimePicker.this.selectedDayIndex));
                    }
                }
            });
            linearLayout.addView(createWheelView);
            if (!TextUtils.isEmpty(this.yearLabel)) {
                TextView createLabelView = createLabelView();
                createLabelView.setTextSize(this.textSize);
                createLabelView.setText(this.yearLabel);
                linearLayout.addView(createLabelView);
            }
        }
        if (this.dateMode != -1) {
            createWheelView2.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
            createWheelView2.setItems(this.months, this.selectedMonthIndex);
            createWheelView2.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DateTimePicker.2
                @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
                public void onSelected(int i5) {
                    int i6;
                    DateTimePicker.this.selectedMonthIndex = i5;
                    String str = (String) DateTimePicker.this.months.get(DateTimePicker.this.selectedMonthIndex);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onMonthWheeled(DateTimePicker.this.selectedMonthIndex, str);
                    }
                    if (DateTimePicker.this.dateMode == 0 || DateTimePicker.this.dateMode == 2) {
                        LogUtils.verbose(this, "change days after month wheeled");
                        if (DateTimePicker.this.resetWhileWheel) {
                            DateTimePicker.this.selectedDayIndex = 0;
                        }
                        if (DateTimePicker.this.dateMode == 0) {
                            i6 = DateUtils.trimZero(DateTimePicker.this.getSelectedYear());
                        } else {
                            i6 = Calendar.getInstance(Locale.CHINA).get(1);
                        }
                        DateTimePicker.this.changeDayData(i6, DateUtils.trimZero(str));
                        createWheelView3.setItems(DateTimePicker.this.days, DateTimePicker.this.selectedDayIndex);
                        if (DateTimePicker.this.onWheelListener != null) {
                            DateTimePicker.this.onWheelListener.onDayWheeled(DateTimePicker.this.selectedDayIndex, (String) DateTimePicker.this.days.get(DateTimePicker.this.selectedDayIndex));
                        }
                    }
                }
            });
            linearLayout.addView(createWheelView2);
            if (!TextUtils.isEmpty(this.monthLabel)) {
                TextView createLabelView2 = createLabelView();
                createLabelView2.setTextSize(this.textSize);
                createLabelView2.setText(this.monthLabel);
                linearLayout.addView(createLabelView2);
            }
        }
        int i5 = this.dateMode;
        if (i5 == 0 || i5 == 2) {
            createWheelView3.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
            createWheelView3.setItems(this.days, this.selectedDayIndex);
            createWheelView3.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DateTimePicker.3
                @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
                public void onSelected(int i6) {
                    DateTimePicker.this.selectedDayIndex = i6;
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onDayWheeled(DateTimePicker.this.selectedDayIndex, (String) DateTimePicker.this.days.get(DateTimePicker.this.selectedDayIndex));
                    }
                }
            });
            linearLayout.addView(createWheelView3);
            if (!TextUtils.isEmpty(this.dayLabel)) {
                TextView createLabelView3 = createLabelView();
                createLabelView3.setTextSize(this.textSize);
                createLabelView3.setText(this.dayLabel);
                linearLayout.addView(createLabelView3);
            }
        }
        if (this.timeMode != -1) {
            createWheelView4.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
            createWheelView4.setItems(this.hours, this.selectedHour);
            createWheelView4.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DateTimePicker.4
                @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
                public void onSelected(int i6) {
                    DateTimePicker dateTimePicker = DateTimePicker.this;
                    dateTimePicker.selectedHour = (String) dateTimePicker.hours.get(i6);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onHourWheeled(i6, DateTimePicker.this.selectedHour);
                    }
                    LogUtils.verbose(this, "change minutes after hour wheeled");
                    DateTimePicker dateTimePicker2 = DateTimePicker.this;
                    dateTimePicker2.changeMinuteData(DateUtils.trimZero(dateTimePicker2.selectedHour));
                    createWheelView5.setItems(DateTimePicker.this.minutes, DateTimePicker.this.selectedMinute);
                }
            });
            linearLayout.addView(createWheelView4);
            if (!TextUtils.isEmpty(this.hourLabel)) {
                TextView createLabelView4 = createLabelView();
                createLabelView4.setTextSize(this.textSize);
                createLabelView4.setText(this.hourLabel);
                linearLayout.addView(createLabelView4);
            }
            createWheelView5.setLayoutParams(new LinearLayout.LayoutParams(0, -2, 1.0f));
            createWheelView5.setItems(this.minutes, this.selectedMinute);
            createWheelView5.setOnItemSelectListener(new WheelView.OnItemSelectListener() { // from class: cn.qqtheme.framework.picker.DateTimePicker.5
                @Override // cn.qqtheme.framework.widget.WheelView.OnItemSelectListener
                public void onSelected(int i6) {
                    DateTimePicker dateTimePicker = DateTimePicker.this;
                    dateTimePicker.selectedMinute = (String) dateTimePicker.minutes.get(i6);
                    if (DateTimePicker.this.onWheelListener != null) {
                        DateTimePicker.this.onWheelListener.onMinuteWheeled(i6, DateTimePicker.this.selectedMinute);
                    }
                }
            });
            linearLayout.addView(createWheelView5);
            if (!TextUtils.isEmpty(this.minuteLabel)) {
                TextView createLabelView5 = createLabelView();
                createLabelView5.setTextSize(this.textSize);
                createLabelView5.setText(this.minuteLabel);
                linearLayout.addView(createLabelView5);
            }
        }
        return linearLayout;
    }

    @Override // cn.qqtheme.framework.popup.ConfirmPopup
    protected void onSubmit() {
        if (this.onDateTimePickListener == null) {
            return;
        }
        String selectedYear = getSelectedYear();
        String selectedMonth = getSelectedMonth();
        String selectedDay = getSelectedDay();
        String selectedHour = getSelectedHour();
        String selectedMinute = getSelectedMinute();
        int i = this.dateMode;
        if (i == -1) {
            ((OnTimePickListener) this.onDateTimePickListener).onDateTimePicked(selectedHour, selectedMinute);
        } else if (i == 0) {
            ((OnYearMonthDayTimePickListener) this.onDateTimePickListener).onDateTimePicked(selectedYear, selectedMonth, selectedDay, selectedHour, selectedMinute);
        } else if (i == 1) {
            ((OnYearMonthTimePickListener) this.onDateTimePickListener).onDateTimePicked(selectedYear, selectedMonth, selectedHour, selectedMinute);
        } else if (i != 2) {
        } else {
            ((OnMonthDayTimePickListener) this.onDateTimePickListener).onDateTimePicked(selectedMonth, selectedDay, selectedHour, selectedMinute);
        }
    }

    private int findItemIndex(ArrayList<String> arrayList, int i) {
        int binarySearch = Collections.binarySearch(arrayList, Integer.valueOf(i), new Comparator<Object>() { // from class: cn.qqtheme.framework.picker.DateTimePicker.6
            @Override // java.util.Comparator
            public int compare(Object obj, Object obj2) {
                String obj3 = obj.toString();
                String obj4 = obj2.toString();
                if (obj3.startsWith("0")) {
                    obj3 = obj3.substring(1);
                }
                if (obj4.startsWith("0")) {
                    obj4 = obj4.substring(1);
                }
                try {
                    return Integer.parseInt(obj3) - Integer.parseInt(obj4);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                    return 0;
                }
            }
        });
        if (binarySearch >= 0) {
            return binarySearch;
        }
        throw new IllegalArgumentException("Item[" + i + "] out of range");
    }

    private void initYearData() {
        this.years.clear();
        int i = this.startYear;
        int i2 = this.endYear;
        if (i == i2) {
            this.years.add(String.valueOf(i));
        } else if (i < i2) {
            while (i <= this.endYear) {
                this.years.add(String.valueOf(i));
                i++;
            }
        } else {
            while (i >= this.endYear) {
                this.years.add(String.valueOf(i));
                i--;
            }
        }
        if (this.resetWhileWheel) {
            return;
        }
        int i3 = this.dateMode;
        if (i3 == 0 || i3 == 1) {
            int indexOf = this.years.indexOf(DateUtils.fillZero(Calendar.getInstance().get(1)));
            if (indexOf == -1) {
                this.selectedYearIndex = 0;
            } else {
                this.selectedYearIndex = indexOf;
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void changeMonthData(int i) {
        String str;
        int i2;
        int i3 = 1;
        if (this.resetWhileWheel) {
            str = "";
        } else {
            int size = this.months.size();
            int i4 = this.selectedMonthIndex;
            if (size > i4) {
                str = this.months.get(i4);
            } else {
                str = DateUtils.fillZero(Calendar.getInstance().get(2) + 1);
            }
            LogUtils.verbose(this, "preSelectMonth=" + str);
        }
        this.months.clear();
        int i5 = this.startMonth;
        if (i5 < 1 || (i2 = this.endMonth) < 1 || i5 > 12 || i2 > 12) {
            throw new IllegalArgumentException("Month out of range [1-12]");
        }
        int i6 = this.startYear;
        int i7 = this.endYear;
        if (i6 == i7) {
            if (i5 > i2) {
                while (i2 >= this.startMonth) {
                    this.months.add(DateUtils.fillZero(i2));
                    i2--;
                }
            } else {
                while (i5 <= this.endMonth) {
                    this.months.add(DateUtils.fillZero(i5));
                    i5++;
                }
            }
        } else if (i == i6) {
            while (i5 <= 12) {
                this.months.add(DateUtils.fillZero(i5));
                i5++;
            }
        } else if (i == i7) {
            while (i3 <= this.endMonth) {
                this.months.add(DateUtils.fillZero(i3));
                i3++;
            }
        } else {
            while (i3 <= 12) {
                this.months.add(DateUtils.fillZero(i3));
                i3++;
            }
        }
        if (this.resetWhileWheel) {
            return;
        }
        int indexOf = this.months.indexOf(str);
        if (indexOf == -1) {
            indexOf = 0;
        }
        this.selectedMonthIndex = indexOf;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void changeDayData(int i, int i2) {
        String str;
        int calculateDaysInMonth = DateUtils.calculateDaysInMonth(i, i2);
        if (this.resetWhileWheel) {
            str = "";
        } else {
            if (this.selectedDayIndex >= calculateDaysInMonth) {
                this.selectedDayIndex = calculateDaysInMonth - 1;
            }
            int size = this.days.size();
            int i3 = this.selectedDayIndex;
            if (size > i3) {
                str = this.days.get(i3);
            } else {
                str = DateUtils.fillZero(Calendar.getInstance().get(5));
            }
            LogUtils.verbose(this, "maxDays=" + calculateDaysInMonth + ", preSelectDay=" + str);
        }
        this.days.clear();
        if (i == this.startYear && i2 == this.startMonth && i == this.endYear && i2 == this.endMonth) {
            for (int i4 = this.startDay; i4 <= this.endDay; i4++) {
                this.days.add(DateUtils.fillZero(i4));
            }
        } else if (i == this.startYear && i2 == this.startMonth) {
            for (int i5 = this.startDay; i5 <= calculateDaysInMonth; i5++) {
                this.days.add(DateUtils.fillZero(i5));
            }
        } else {
            int i6 = 1;
            if (i == this.endYear && i2 == this.endMonth) {
                while (i6 <= this.endDay) {
                    this.days.add(DateUtils.fillZero(i6));
                    i6++;
                }
            } else {
                while (i6 <= calculateDaysInMonth) {
                    this.days.add(DateUtils.fillZero(i6));
                    i6++;
                }
            }
        }
        if (this.resetWhileWheel) {
            return;
        }
        int indexOf = this.days.indexOf(str);
        if (indexOf == -1) {
            indexOf = 0;
        }
        this.selectedDayIndex = indexOf;
    }

    private void initHourData() {
        int i;
        this.hours.clear();
        if (this.resetWhileWheel) {
            i = 0;
        } else if (this.timeMode == 3) {
            i = Calendar.getInstance().get(11);
        } else {
            i = Calendar.getInstance().get(10);
        }
        for (int i2 = this.startHour; i2 <= this.endHour; i2++) {
            String fillZero = DateUtils.fillZero(i2);
            if (!this.resetWhileWheel && i2 == i) {
                this.selectedHour = fillZero;
            }
            this.hours.add(fillZero);
        }
        if (this.hours.indexOf(this.selectedHour) == -1) {
            this.selectedHour = this.hours.get(0);
        }
        if (this.resetWhileWheel) {
            return;
        }
        this.selectedMinute = DateUtils.fillZero(Calendar.getInstance().get(12));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void changeMinuteData(int i) {
        this.minutes.clear();
        int i2 = this.startHour;
        int i3 = this.endHour;
        if (i2 == i3) {
            int i4 = this.startMinute;
            int i5 = this.endMinute;
            if (i4 > i5) {
                this.startMinute = i5;
                this.endMinute = i4;
            }
            for (int i6 = this.startMinute; i6 <= this.endMinute; i6++) {
                this.minutes.add(DateUtils.fillZero(i6));
            }
        } else if (i == i2) {
            for (int i7 = this.startMinute; i7 <= 59; i7++) {
                this.minutes.add(DateUtils.fillZero(i7));
            }
        } else if (i == i3) {
            for (int i8 = 0; i8 <= this.endMinute; i8++) {
                this.minutes.add(DateUtils.fillZero(i8));
            }
        } else {
            for (int i9 = 0; i9 <= 59; i9++) {
                this.minutes.add(DateUtils.fillZero(i9));
            }
        }
        if (this.minutes.indexOf(this.selectedMinute) == -1) {
            this.selectedMinute = this.minutes.get(0);
        }
    }
}
